package com.ssy.lingxi.logistics.controller.mobile;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.logistics.model.request.MobileCompanyAddRequest;
import com.ssy.lingxi.logistics.model.response.mobile.MobileCompanyListResponse;
import com.ssy.lingxi.logistics.service.IMobileCompanyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu APP-退货-物流公司相关接口
 * @author yzc
 * @version 2.0.0
 * @date 2020/7/10
 */
@RestController
@RequestMapping("/logistics/mobile/company")
public class MobileCompanyController extends BaseController {
    @Resource
    private IMobileCompanyService mobileCompanyService;


    /**
     * 查看物流公司列表
     * @return 返回结果
     */
    @GetMapping("/list")
    public Wrapper<List<MobileCompanyListResponse>> listCompany() {
        UserLoginCacheDTO sysUser = getSysUser();
        return mobileCompanyService.listCompany(sysUser);
    }

    /**
     * 添加物流公司
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping(value = "/add")
    public Wrapper<Void> addCompany(@RequestBody @Valid MobileCompanyAddRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return mobileCompanyService.addCompany(request, sysUser);
    }
}
